package com.yaxiya.login.service;

import java.sql.SQLException;

import com.yaxiya.login.entity.YongHu;
import com.yaxiya.util.DBManager;
import com.yaxiya.util.QueryDataResult;

public class YongHuServiceImpl {

	public YongHu queryByOne(YongHu yh) {
		YongHu yonghu=null;
		String sql = "select * from yonghu where name="+ yh.getName()+" and pwd="+ yh.getPwd();
		QueryDataResult query = DBManager.executeQuery(sql);
		if (query.rs != null) {
			try {
				while (query.rs.next()) {
					int id = query.rs.getInt("id");
					String name = query.rs.getString("name");
					String pwd = query.rs.getString("pwd");
					yonghu = new YongHu(id, name, pwd);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return yonghu;
	}

}
